<template>
  <a-modal 
    :visible="visible"
    okText="提交" 
    cancelText="取消" 
    :title="title"
    :destroyOnClose="true"
    :maskClosable="false"
    :keyboard="false"
    :width="1000"
    @cancel="closeModal()" 
    @ok="handleSubmit">
    <search-table :url="url" ref="searchtable" :columns="columns" :form="form">
      <template slot="searchForm">
        <a-form layout="inline" :form="form">
          <a-form-item label="店铺名称">
            <a-input
              v-decorator="[
                'galleryProductName',
              ]"
              placeholder="请输入店铺名称"
            >
            </a-input>
          </a-form-item>
        </a-form>
      </template>
    </search-table>
  </a-modal>
</template>

<script>
export default {
  name: 'user-info',
  props: {
    record: {
      type: Object,
      default() {
        return {}
      }
    },
    visible: {
      type: Boolean,
      default: false
    },
  },
  computed: {
    title () {
      return '选择店铺'
    },    
  },
  data () {
    return {
      url: '/gallery/product/page',
      form: this.$form.createForm(this, { name: 'table_search' }),
      columns:  [
        {
          title:'编号',
          dataIndex:'largeScreenPicture',
          key:'largeScreenPicture',
        },
        {
          title: '店铺名称',
          dataIndex: 'shopName',
          key: 'shopName',
        },
        {
          title: '店铺类型',
          dataIndex: 'userName',
          key: 'userName',
        },
        {
          title:'所属机构',
          dataIndex:'orgId',
          key:'orgId'
        },
        {
          title:'最后操作时间',
          dataIndex:'updateTime',
          key:'updateTime'
        },
        {
          title:'联系人',
          dataIndex:'peopleName',
          key:'peopleName'
        },
        {
          title:'联系电话',
          dataIndex:'peoplePhone',
          key:'peoplePhone'
        }
      ]
    }
  },
  watch: {
    // visible (value) {
    //   if (value && this.record.id) {
    //     this.$nextTick(()=> {
    //       const formItems = this.form.getFieldsValue();
    //       Object.keys(formItems).forEach(key => {
    //         formItems[key] = this.record[key]
    //       })
    //       this.form.setFieldsValue(formItems);
    //     })
    //   }
    // }
  },
  created(){
    
  },
  methods: {
    handleSubmit(){
      let selectedIds=this.$refs.searchtable.selectedRowKeys;
      console.log(selectedIds);
      this.closeModal(true)
    },
    closeModal (freshTable) {
      this.$emit('cancel', freshTable)
    },
  }
}
</script>

<style lang="less" scoped>
  .avatar_img{
    max-width:104px;
  }
</style>
